<?php
defined('BASEPATH') or exit('No direct script access allowed');
require APPPATH.'libraries/BaseApiController.php';
class User extends BaseApiController
{
	public function __construct()
	{
	    parent::__construct();
	}
	function index(){
		 
	}
	
	public function login(){
		$data=$this->getKeys([
		  ['username',True,"账号"],
		  ['password',True,"密码"]
 		],'post');
		
		$user=$this->db->where("username",$data["username"])->get("user")->row_array();
		if($user){
			if($user["password"]==$data["password"]){
				$this->WRITE("user",$user);
				$this->RESPONSE();
			}else{
				$this->WRITE("code",0);
				$this->WRITE("msg","账号或密码错误!");
				$this->RESPONSE();
			}
			
		}else{
			$this->WRITE("code",0);
			$this->WRITE("msg","账号或密码错误!");
			$this->RESPONSE();
		}
	}
}